<template>
  <el-container class="custom-container-style">
    <el-header class="custom-header-style">
      <h1>综治信息大数据</h1>
      <!--<div class="return" @click="back()"></div>-->
      <a class="backHome" title="返回首页" href="/"><em class="iconfont el-icon-extend-shouye" style="font-size: 32px;color: #1ab2ca"></em></a>
      <!-- <div id="menuInterlayer"></div> -->
      <div class="custom-data-menu-style">
        <ul>
          <!--<li v-for="menu in menus" :index="menu.uri" :key="menu.id" @click="menuHandleSelectEvt(menu)">{{menu.name}}</li>-->
          <li :class="activeClass == index ? 'active' : '' " v-for="(item, index) in menus" :key="index" @click="getItem(item, index)">
            {{item.name}}
          </li>
        </ul>
      </div>
    </el-header>
    <el-main class="el-main">
      <router-view />
    </el-main>
  </el-container>
</template>

<script>
import { getUserPermissionTree, getActiveModuleId } from '@/utils/SessionDataUtil'
export default {
  data () {
    return {
      activeIndex2: '1',
      menuList: [],
      menus: [],
      activeClass: -1
    }
  },
  created () {
    let activeModule = getActiveModuleId()
    this.getMenus(activeModule)
    this.$router.push({path: 'zongzhi'})
    this.activeClass = '0'
  },
  methods: {
    getItem (item, index) {
      this.$router.push({path: item.uri})
      this.activeClass = index
    },
    // menuHandleSelectEvt (data) {
    //   this.$router.push({path: data.uri})
    // },
    getMenus (activeModule) {
      if (!activeModule) {
        this.$router.push({ path: '/' })
      } else {
        let permissionInfo = getUserPermissionTree()
        let currentMenuData = {}
        for (let i = 0; i < permissionInfo.length; i++) {
          if (activeModule === permissionInfo[i].id) {
            currentMenuData = permissionInfo[i]
          }
        }
        if (currentMenuData.length === 0) this.$router.push({ path: '/' })
        this.buildMenus(currentMenuData)
      }
    },
    buildMenus (menus) {
      if (menus && menus.name !== '系统设置' && menus.children) {
        this.menus = menus.children
      } else {
        this.menus = [menus]
      }
      this.menuList = this.menus[0].children
    },
    back () {
      this.$router.push({path: '首页'})
    }
  }
}
</script>

<style scoped>
  .el-main{
    overflow-x: hidden
  }
  .el-main::-webkit-scrollbar{
    display: none
  }
  #menuInterlayer{
    width: 100%;
    height: 60px;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 9999;
    background-color: #01144b;
    opacity: 0.8;
    border-radius: 6px;
  }
  .custom-data-menu-style ul li:hover{
    background: linear-gradient(to bottom, rgba(14, 102, 180,0), rgba(14, 102, 180,1));
    border-bottom: 4px solid #07a6ff;
  }
  .active{
    background: linear-gradient(to bottom, rgba(14, 102, 180,0), rgba(14, 102, 180,1));
    border-bottom: 4px solid #07a6ff;
  }
  .el-header {
    color: white;
    line-height: 25px;
    padding: 0;
    margin-bottom: 20px;
  }
  /*.return{*/
    /*width: 37px;*/
    /*height: 36px;*/
    /*background-image: url('~@/assets/bigdata/img/return3.png');*/
    /*background-repeat: no-repeat;*/
    /*background-size: 100% 100%;*/
    /*position: absolute;*/
    /*top: 2%;*/
    /*left: 0.2%;*/
  /*}*/
  /*.return:hover{*/
    /*cursor:pointer;*/
  /*}*/
  .backHome {
    position: absolute;
    right: -10px;
    top: 6px;
    width: 100px;
    height: 35px;
    line-height: 35px;
    text-align: center;
    font-size: 16px;
    color: #fff;
    text-decoration:none
  }
</style>
